package com.hisense.ovcloud.apicontrol.service;

import cn.hutool.core.util.IdUtil;
import com.hisense.ovcloud.apicontrol.dto.resp.DynamicKeyResp;
import com.hisense.ovcloud.apicontrol.tool.HiAESUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import reactor.core.publisher.Mono;

@Service
@Slf4j
public class SecurityService {
    public Mono<DynamicKeyResp> getDynamicKey() {
        String uuid = IdUtil.fastUUID().replaceAll("-", "").substring(0, 32);
        String encryptedUuid = new HiAESUtil().enc(uuid);
        log.info("generated dKey: {}, eDKey: {}", uuid, encryptedUuid);
        return Mono.just(DynamicKeyResp.builder().dkey(uuid).eDKey(encryptedUuid).build());
    }
}
